package bancosys.tec.services.implementor.annotations.visitor;

import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Collections;

import jmine.tec.di.metadata.DependencyMetaData;
import jmine.tec.di.metadata.impl.DependencyMetaDataImpl;
import jmine.tec.di.resolver.impl.AllObjetsResolver;
import jmine.tec.di.wrapper.Wrappers;
import jmine.tec.services.annotations.AllProperties;

/**
 * @author takeshi
 */
public class AllPropertiesAnnotationVisitor extends SetterAndParametersAnnotationVisitor<DependencyMetaData> {

    /**
     * C'tor
     */
    public AllPropertiesAnnotationVisitor() {
        super(AllProperties.class);
    }

    /**
     * {@inheritDoc}
     * 
     * @see jmine.tec.utils.annotation.visitor.AnnotationVisitorAdapter#onParameterAnnotation(java.lang.annotation.Annotation,
     * java.lang.Class, int, java.lang.Class, java.lang.reflect.Type, java.lang.reflect.Member)
     */
    @Override
    protected Collection<? extends DependencyMetaData> onParameterAnnotation(Annotation annotation, Class<?> annotated, int parameterIndex,
            Class<?> parameterType, Type genericType, Member annotatedMember) {
        return Collections.singleton(new DependencyMetaDataImpl("*", new AllObjetsResolver(), false,
                Wrappers.findWrapperFor(parameterType), Object.class));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Collection<? extends DependencyMetaData> onPropertySetterAnnotation(Annotation annotation, Class<?> declaringClass,
            String propertyName, Class<?> propertyRawType, Type generictType) {
        return Collections.singleton(new DependencyMetaDataImpl("*", new AllObjetsResolver(), false, Wrappers
                .findWrapperFor(propertyRawType), Object.class));
    }

}
